#include "stdafx.h"
#include "hash/hash.hpp"

namespace JHCPP
{
	namespace hash
	{
		std::size_t hash(Int8 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(UInt8 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(Int16 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(UInt16 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(Int32 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(UInt32 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(Int64 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(UInt64 n)
		{
			return static_cast<std::size_t>(n)*2654435761U; 
		}

		std::size_t hash(const std::string& str)
		{
			std::size_t h = 0;
			std::string::const_iterator it  = str.begin();
			std::string::const_iterator end = str.end();
			while (it != end)
			{
				h = h * 0xf4243 ^ *it++;
			}
			return h;
		}
	}//end of namespace hash
}//end of namespace JHCPP
